<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/9/2
  Time: 上午10:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" href="css/layui.css">
    <script src="js/jquery-1.8.0.min.js"></script>
    <script src="layui.js"></script>
</head>
<body>

<table id="demo" lay-filter="test"></table>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">转账</a>
</script>

<script>
    layui.use('table', function () {
        var table = layui.table;
        //第一个实例
        table.render({
            elem: '#demo'
            , height: 312
            , url: 'selectservlet' //数据接口
            , page: true //开启分页
            , parseData: function (res) {
                return {
                    "code": 0,
                    "msg": "请求成功",
                    "count": 1000,
                    "data": res
                }
            }
            , cols: [[ //表头
                {field: 'id', title: 'ID', sort: true, fixed: 'left'}
                , {field: 'name', title: '姓名'}
                , {field: 'kahao', title: '银行卡号', sort: true}
                , {field: 'iphone', title: '手机号码'}
                , {field: 'money', title: '余额'}
                , {field: 'experience', title: '操作', toolbar: '#barDemo'}
            ]]
        });
        //触发行单击事件
        table.on('tool(test)', function (obj) {
            console.log(obj)
            console.log(obj.event)
            console.log(obj.data.id)
            if (obj.event == 'detail') {
                location.href = "<%=request.getContextPath()%>/selectIdServlet?sid=" + obj.data.id;
            }
        });
    });
</script>

<%--<table id="mytable" border="1">--%>
<%--    <tr>--%>
<%--        <td>编号</td>--%>
<%--        <td>姓名</td>--%>
<%--        <td>银行卡号</td>--%>
<%--        <td>手机号码</td>--%>
<%--        <td>余额</td>--%>
<%--        <td>操作</td>--%>
<%--    </tr>--%>
<%--</table>--%>
<%--<script>--%>
<%--    $(document).ready(function () {--%>
<%--        $(function () {--%>
<%--            $.getJSON("selectservlet", show);--%>
<%--        })--%>

<%--        function show(data) {--%>
<%--            $(data).each(function (index, v) {--%>
<%--                $("#mytable").append("<tr><td>" + v.id + "</td> <td>" + v.name + "</td><td>" + v.kahao + "</td><td>" + v.iphone + "</td><td>" + v.money + "</td><td><a href='<%=request.getContextPath()%>/selectIdServlet?sid=" + v.id + "'>转账</a></td></tr>")--%>
<%--            });--%>
<%--        }--%>
<%--    })--%>
<%--</script>--%>
</body>
</html>
